/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chating;
/**
 *
 * @author Andi
 */
public class Message {
    // attributes
    public static int availableMessageID = 0;
    private int messageID;
    private String poster;
    private String contentPost;
    private long timePost;

    // constructor
    public Message(){}
    public Message(String namePost, String contentPost){
        this.messageID = availableMessageID;
        this.poster = namePost;
        this.contentPost = contentPost;
        this.timePost = System.currentTimeMillis();
        availableMessageID++;
    }
    public Message(Message m){
        this.messageID = m.getMessageID();
        this.poster = m.getNamePost();
        this.contentPost = m.getContentPost();
        this.timePost = m.getTimePost();
        availableMessageID++;
    }

    // getter and setter
    /**
     * @return the namePost
     */
    public String getNamePost() {
        return poster;
    }

    /**
     * @param namePost the namePost to set
     */
    public void setNamePost(String namePost) {
        this.poster = namePost;
    }

    /**
     * @return the contentPost
     */
    public String getContentPost() {
        return contentPost;
    }

    /**
     * @param contentPost the contentPost to set
     */
    public void setContentPost(String contentPost) {
        this.contentPost = contentPost;
    }

    /**
     * @return the timePost
     */
    public long getTimePost() {
        return timePost;
    }

    /**
     * @param timePost the timePost to set
     */
    public void setTimePost(long timePost) {
        this.timePost = timePost;
    }

    /**
     * @return the messageID
     */
    public int getMessageID() {
        return messageID;
    }

    /**
     * @param messageID the messageID to set
     */
    public void setMessageID(int messageID) {
        this.messageID = messageID;
    }

    //methods
    public String chatToString(){
        String s = this.poster + " " + this.timePost + " " + this.contentPost;
        return s;
    }

}
